/**
 * 
 */
package blaze.homebank.server;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import blaze.homebank.client.Home;
import blaze.homebank.client.HomeService;
import blaze.homebank.client.LoginInfo;

/**
 * @author dzikun
 *
 */
@SuppressWarnings("serial")
public class HomeServiceImpl extends RemoteServiceServlet implements HomeService {
	private static int index = 0;
	
	private List<Home> homes = new ArrayList<Home>();
	/* (non-Javadoc)
	 * @see blaze.homebank.client.HomeService#addHome(blaze.homebank.client.LoginInfo, blaze.homebank.client.Home)
	 */
	@Override
	public boolean addHome(LoginInfo user, Home home) {
		if (homes.size() < 10) {
			homes.add(home);
			return true;
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see blaze.homebank.client.HomeService#delHome(blaze.homebank.client.LoginInfo, blaze.homebank.client.Home)
	 */
	@Override
	public boolean delHome(LoginInfo user, Home home) {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see blaze.homebank.client.HomeService#getHomes(blaze.homebank.client.LoginInfo)
	 */
	@Override
	public Home[] getHomes(LoginInfo user) {
		Home[] result = new Home[homes.size()];
		for (int i = 0; i < homes.size(); i++) {
			result[i] = homes.get(i);
		}
		return result;
	}

}
